﻿
$(document).ready(function () {
    $('#addcomments').bind('blur', function () {
        var line = "-------------------------------------------------------";
        var myDate = new Date();
        var myFormattedDate = myDate.f("dd/MM/yyyy HH:mm:ss");
        $("#DetailsView0_Comments").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate + ' - ' + $('#addcomments').val() + '\n' + line + '\n');
    });

    if ($('#DetailsView0_lbluserID').text() == '') {
        if ($('#DetailsView0_StatusName').val() == '') {
            $("#DetailsView0_StatusName").val('Status Not Set');
        }
    }

});


	function CurrentProvider0Changed() {
		$("#DetailsView0_CurrentProvider").val($('#DetailsView0_selCurrentProvider').val());
	}

    function NewProvider0Changed() {
        $("#DetailsView0_NewProvider").val($('#DetailsView0_selNewProvider').val());
    }


    function StateName0Changed() {
        $("#DetailsView0_StateName").val($('#DetailsView0_selStateName').val());
    }

    function PreferredTime0Changed() {
        $("#DetailsView0_PreferredTime").val($('#DetailsView0_selPreferredTime').val());
    }


    function PromotionCode0Changed() {
        $("#DetailsView0_PromotionCode").val($('#DetailsView0_selPromotionCode').val());
		$("#DetailsView0_LeadSource").val($('#DetailsView0_selPromotionCode').val());
        if ($('#DetailsView0_PromotionCode').val() == '') {
            $("#DetailsView0_LeadSource").val('');
        }

        if ($('#DetailsView0_PromotionCode').val() == 'CRICKET NSW CLUBS') {
            $("#DetailsView0_LeadSource").val('CRICKET NSW');
        }
        if ($('#DetailsView0_PromotionCode').val() == 'CRICKET NSW') {
            $("#DetailsView0_LeadSource").val('CRICKET NSW');
        }

        if ($('#DetailsView0_PromotionCode').val() == 'SEA EAGLES') {
            $("#DetailsView0_LeadSource").val('SEA EAGLES');
        }
        if ($('#DetailsView0_PromotionCode').val() == 'SEA EAGLES B2B') {
            $("#DetailsView0_LeadSource").val('SEA EAGLES');
        }

    }

    function AccountStatus0Changed() {
        $("#DetailsView0_StatusName").val($('#DetailsView0_selAccountStatus').val());
        var myDate = new Date();
        var myFormattedDate1 = myDate.f("yyyy-MM-dd");
        var myFormattedDate2 = myDate.f("dd/MM/yyyy HH:mm:ss");
        var mytext = $('#DetailsView0_selAccountStatus').val();
        $("#DetailsView0_AccountStatusHistory").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate2 + ' - ' + mytext + '\n');
        if ($('#DetailsView0_selAccountStatus').val() == 'Converted') {
            $("#DetailsView0_DateConverted").val(myFormattedDate1);
        }
    }

    function OperatorSSE0Changed() {

        $("#DetailsView0_OperatorSSE").val($('#DetailsView0_selOperatorSSE').val());
    }

    function TypeOrg0Changed() {

        $("#DetailsView0_TypeOrg").val($('#DetailsView0_selTypeOrg').val());
    }

